package stone;

import ASTInterpreter.ArrayEnv;
import ASTInterpreter.Environment;
import stone.ast.BlockStmnt;
import stone.ast.OptFunction;
import stone.ast.ParameterList;

public class OptMethod extends OptFunction {

	OptStoneObject self;
	
	public OptMethod(ParameterList parameters, BlockStmnt body,
			Environment env, int memorySize, OptStoneObject self) {
		super(parameters, body, env, memorySize);
		this.self = self;
	}
	
	@Override
	public Environment makeEnv() {
		// 准备一个用于执行新方法的环境
		// 它将在环境数组的第一个元素中保存对象OptStoneObject的引用
		ArrayEnv e = new ArrayEnv(size, env);
		e.put(0, 0, self);
		return e;
	}

}
